﻿

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Profile;

using Gift.DAL;
using Gift.Model;


namespace WebSite.admin.product
{
    public partial class goodsCompanyEdit02 : BaseAdmin
    {

        readonly dalGoodsCompany theGoodsCompany = new dalGoodsCompany();
        tbGoodsCompany oGoodsCompany;

        // Methods
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

            if (base.Request.QueryString["gid"] != null)
            {
                if (this.txtInstiturion.Text.Length > 1000)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.Page.ClientScript.GetType(), "msg", "<script>alert(\"简介字数不能超过1000个！\")</script>");
                    //ExtAspNet.Alert.Show("简介字数不能超过1000个！");
                    return;
                }
                oGoodsCompany = theGoodsCompany.GetModel(int.Parse(Request.QueryString["gid"]));
                oGoodsCompany.instruction = this.txtInstiturion.Text.Replace("'", "''");
                oGoodsCompany.goodsContent = this.txtaContent.InnerText.Replace("'", "''");
                theGoodsCompany.Update(oGoodsCompany);
                Page.ClientScript.RegisterClientScriptBlock(this.Page.ClientScript.GetType(), "msg", "<script>alert(\"产品详细描述修改成功！\")</script>");
             //   ExtAspNet.Alert.Show("产品详细描述修改成功！");
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.Page.ClientScript.GetType(), "msg", "<script>alert(\"请先添加商品基本信息！\")</script>");
              //  ExtAspNet.Alert.Show("请先添加商品基本信息！");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!base.IsPostBack)
            {
                this.BindForm();
            }
        }

        private void BindForm()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["gid"]))
            {
                oGoodsCompany = theGoodsCompany.GetModel(int.Parse(Request.QueryString["gid"]));
                if (oGoodsCompany.goodsContent != null)
                {
                    this.txtaContent.InnerText = oGoodsCompany.goodsContent.ToString().Replace("''", "'");
                }
                if (oGoodsCompany.instruction != null)
                {
                    this.txtInstiturion.Text = oGoodsCompany.instruction.ToString().Replace("''", "'");
                }

            }
            if(this.txtInstiturion.Text.Trim() == "")
            {
                this.txtInstiturion.Text = "品牌：\n品名：\n规格：";
            }

        }


    }
}